home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist / dist6.3 / gl_dev.idb / usr / include / gl / dgl.h.z / dgl.h
C/C++ Source or Header  |  1996-12-06  |  24KB  |  624 lines

  1. #ifndef __GL_DGL_H__
  2. #define __GL_DGL_H__
  3. /**************************************************************************
  4.  *                                      *
  5.  *          Copyright (C) 1989, Silicon Graphics, Inc.          *
  6.  *                                      *
  7.  *  These coded instructions, statements, and computer programs  contain  *
  8.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  9.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  10.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  11.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  12.  *                                      *
  13.  **************************************************************************/
  14. /*----------------------------------------------------------------------*/
  15. /* dgl.h */
  16. /*  - Header file used to build the DGL, its associated test programs,  */
  17. /*    and dgld. */
  18. /*  - No user application should ever include this file. */
  19. /* */
  20. /* $Revision: 1.31 $ */
  21. /*----------------------------------------------------------------------*/
  22.  
  23.  
  24. /*----------------------------------------------------------------------*/
  25. /*        SECTION 1 - machine dependent statements */
  26. /*----------------------------------------------------------------------*/
  27.  
  28. /*----------------------------------------------------------------------*/
  29. /* IRIS machine dependent statements */
  30. /*----------------------------------------------------------------------*/
  31. #if sgi
  32. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  33. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  34. #if m68000            /* on 3K, times() returns 60'ths regardless */
  35. #undef HZ
  36. #define HZ 60
  37. #define double long float    /* make m68020 behave like everyone else*/
  38. #endif /* m68000 */
  39. #endif /* sgi */
  40.  
  41. /*----------------------------------------------------------------------*/
  42. /* ALLIANT/BSD machine dependent statements */
  43. /*----------------------------------------------------------------------*/
  44. #ifdef ALLIANT
  45. #define alliant 1
  46. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  47. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  48.  
  49. #define __STDC__        /* need to define this when using pcc    */
  50.  
  51.                 /* ALLIANT default is signed chars    */
  52.                 /* Leave the rest of the next line empty*/
  53. #define signed
  54. #define h_errno errno        /* BSD has these merged???        */
  55. typedef unsigned long ulong;    /* missing from types.h            */
  56. #endif /* ALLIANT */
  57.  
  58. /*----------------------------------------------------------------------*/
  59. /* CONVEX machine dependent statements */
  60. /*----------------------------------------------------------------------*/
  61. #if convex
  62. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  63. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  64.  
  65. #undef HZ            /* times() returns 60'ths regardless    */
  66. #define HZ 60
  67. #define strchr index        /* strchr(s,c) equivalent to index(s,c) */
  68. #define signed            /* CONVEX default is signed chars    */
  69. #define h_errno errno        /* BSD has these merged???        */
  70. typedef unsigned long ulong;    /* missing from types.h            */
  71. #endif /* convex */
  72.  
  73. /*----------------------------------------------------------------------*/
  74. /* CRAY machine dependent statements */
  75. /*----------------------------------------------------------------------*/
  76. #ifdef CRAY
  77. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  78. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  79. #define signed            /* CRAY default is signed chars    */
  80. #include <use_stdc.h>        /* Make sure we use the ANSI C compiler. */
  81. #endif /* CRAY */
  82.  
  83. /*----------------------------------------------------------------------*/
  84. /* SUN/BSD machine dependent statements */
  85. /*----------------------------------------------------------------------*/
  86. #if sun
  87. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  88. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  89.  
  90. #define signed            /* SUN default is signed chars        */
  91. #define h_errno errno        /* BSD has these merged???        */
  92. typedef unsigned long ulong;    /* missing from types.h            */
  93. #endif /* sun */
  94.  
  95. /*----------------------------------------------------------------------*/
  96. /* VAX VMS/BSD machine dependent statements */
  97. /*----------------------------------------------------------------------*/
  98. #if vax
  99. #define MACHINE_WORD_FORMAT    DGL_LITTLE_ENDIAN
  100. #define MACHINE_FLOAT_FORMAT    DGL_NON_IEEE
  101.  
  102. #define signed            /* VAX default is signed chars        */
  103.  
  104. #if vms                /* VMS only statements            */
  105. #define    HZ    100        /* missing from param.h            */
  106.  
  107. #define dn_perror dgl_perror    /* use normal error handler        */
  108. #define fork vfork        /* just for now - doesn't really work    */
  109.  
  110. #else                /* VAX/BSD only statements        */
  111. #define HZ 60            /* missing from param.h            */
  112. typedef unsigned long ulong;    /* missing from types.h            */
  113. extern int errno;        /* missing from errno.h            */
  114. #endif /* vms */
  115. #endif /* vax */
  116.  
  117. /*----------------------------------------------------------------------*/
  118. /* IBM RS/6000 series machine dependent statements */
  119. /*----------------------------------------------------------------------*/
  120. #ifdef _IBMR2
  121. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  122. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  123. #undef DOUBLE    /* bogusly defined in <gai/g3dm2types.h> */
  124. #endif
  125.  
  126.  
  127. /*----------------------------------------------------------------------*/
  128. /* 32/64-bit architecture dependent statements */
  129. /*----------------------------------------------------------------------*/
  130. #undef SIZEOF
  131. #ifdef CRAY
  132.  
  133. #define size_char 1
  134. #define size_short 2
  135. #define size_int 4
  136. #define size_long 4
  137. #define size_float 4
  138. #define size_double 8
  139. #define size_Fontchar 8
  140. #define size_Lfontchar 20
  141. #define size_fmglyphinfo 32
  142. #define size_fmfontinfo 212        /* careful with this one */
  143. #ifdef __STDC__
  144. #define SIZEOF(x) size_##x
  145. #else
  146. #define SIZEOF(x) size_/**/x
  147. #endif /*__STDC__*/  
  148.  
  149. /* These macros expect a pointer to the communications buffer; in the case of
  150.    a Cray they do nothing. */
  151. #define DGL_NTOH_LONG_CBUF(p)   {}
  152. #define DGL_NTOH_SHORT_CBUF(p)  {}
  153. #define DGL_NTOH_FLOAT_CBUF(p)  {}
  154.  
  155. /* Store a long(short) with no byteswapping conversion. */
  156. #define PUT_LONG(p,l)    DGL_HTON_LONG( p,l)
  157. #define PUT_SHORT(p,s)     DGL_HTON_SHORT( p,s)
  158.  
  159. /* Make an expression that interprets 4(2) chars as a long(short). */
  160. #define GET_LONG(p) \
  161.     ( (p)[0] & 0x80 ? \
  162.         ((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8  | (p)[3]) \
  163.           | ~0xffffffff \
  164.      : ((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8  | (p)[3]) \
  165.     )
  166. #define GET_SHORT(p) \
  167.     ( (p)[0] & 0x80 ? \
  168.         ((p)[0] << 8 | (p)[1]) | ~0xffff \
  169.       : ((p)[0] << 8 | (p)[1]) \
  170.     )
  171.  
  172. #else /* not CRAY */
  173. #define SIZEOF(x) sizeof(x)
  174.  
  175. /* These macros expect a pointer to the communications buffer; they perform
  176.    byteswapping conversion, if needed, on values found in the buffer. */
  177. #define DGL_NTOH_LONG_CBUF(p)   DGL_NTOH_LONG( LONG(p), LONG(p))
  178. #define DGL_NTOH_SHORT_CBUF(p)  DGL_NTOH_SHORT( SHORT(p), SHORT(p))
  179. #define DGL_NTOH_FLOAT_CBUF(p)  DGL_NTOH_FLOAT( FLOAT(p), FLOAT(p))
  180.  
  181. /* Store a long(short) with no byteswapping conversions. */
  182. #define PUT_LONG(p,l)    (LONG(p) = l)
  183. #define PUT_SHORT(p,s)     (SHORT(p) = s)
  184.  
  185. /* Make an expression that interprets 4(2) chars as a long(short). */
  186. #define GET_LONG(p)    LONG(p)
  187. #define GET_SHORT(p)     SHORT(p)
  188. #define GET_FLOAT(p)     FLOAT(p)
  189.  
  190. #endif /* ifdef CRAY */
  191.  
  192. /*----------------------------------------------------------------------*/
  193. /*        SECTION 2 - capability variables */
  194. /*----------------------------------------------------------------------*/
  195.  
  196. /*----------------------------------------------------------------------*/
  197. /* COMMUNICATION variables */
  198. /*----------------------------------------------------------------------*/
  199.                 
  200. /* supports LOCAL connections */
  201. #define GLLOCAL (sgi && mips)    /* only 4D's, not 3K's */
  202.  
  203. /* supports TCP socket connections */
  204. #define GLTSOCKET sgi || sun || convex || (vax && !vms) || _IBMR2 || cray
  205.  
  206. /* supports DECnet connections */
  207. #define GL4DDN    vms /* || (sgi && mips) *//* 4DDN is only on 4Ds, not 3K's */
  208.  
  209. /*----------------------------------------------------------------------*/
  210. /* SYSTEM/LIBRARY variables */
  211. /*----------------------------------------------------------------------*/
  212. #define CUSERID BSD        /* use our own cuserid() subroutine    */
  213. #define DOPRNT    vms        /* use our own _doprnt subroutine    */
  214. #define GETTIMEOFDAY vms    /* use our own gettimeofday subroutine    */
  215.  
  216. /* private definitions for DGLTYPE variable
  217.  * public values are
  218.  * DGLSINK    0
  219.  * DGLLOCAL    1
  220.  * DGLTSOCKET    2
  221.  * DGL4DDN    3
  222.  */
  223. #define DGLNOTYPE        4    /* default connection    */
  224. #define DGLNOHOST        5    /* default hostname    */
  225.  
  226.  
  227. /*----------------------------------------------------------------------*/
  228. /* MACHINE CAPABILITY variables */
  229. /*----------------------------------------------------------------------*/
  230. #define WORDALIGN mips        /* requires word alignment on copies    */
  231.  
  232.  
  233. /*----------------------------------------------------------------------*/
  234. /*        SECTION 3 - GL renaming macros */
  235. /*----------------------------------------------------------------------*/
  236.  
  237. /* 
  238.  * GLCMD is the macro used to redefine all GL names
  239.  * FGLCMD is the macro used to redefine all FGL names
  240.  */
  241.  
  242. #ifdef GLBUILD
  243. #define GLCMD(name) gl_d_/**/name
  244. #else
  245. #define GLCMD(name) name
  246. #endif
  247.  
  248. #ifdef    __STDC__
  249. #define FGLCMD(name) name##_    
  250. #else
  251. #define FGLCMD(name) name/**/_
  252. #endif
  253.  
  254. #if defined(CRAY) && defined(LIBFGL)
  255. #define FGLNAME(lower,upper) FGLCMD(upper)    /* upper case externals */
  256. #else
  257. #define FGLNAME(lower,upper) FGLCMD(lower)    /* lower case externals */
  258. #endif
  259.  
  260.  
  261. /*----------------------------------------------------------------------*/
  262. /*        SECTION 4 - data conversion */
  263. /*----------------------------------------------------------------------*/
  264.  
  265. /*----------------------------------------------------------------------*/
  266. /* first some defines for the various data formats */
  267. /*----------------------------------------------------------------------*/
  268. #define DGL_LITTLE_ENDIAN 1        /* integer formats        */
  269. #define DGL_BIG_ENDIAN 2
  270.  
  271. #define DGL_BIG_IEEE 1        /* floating point formats    */
  272. #define DGL_NON_IEEE 3
  273.  
  274. /*----------------------------------------------------------------------*/
  275. /* here are the data conversion (byte swapping) algorithms */
  276. /*    HTON - client host to network (server) */
  277. /*    NTOH - network (server) to client host */
  278. /*----------------------------------------------------------------------*/
  279.  
  280. /*----------------------------------------------------------------------*/
  281. /* these macros are the same on all machines because chars need no */
  282. /* conversion whatsoever */
  283. /*----------------------------------------------------------------------*/
  284. #define DGL_HTON_CHAR(t,f) t=f
  285. #define DGL_NTOH_CHAR DGL_HTON_CHAR
  286. #define DGL_HTON_CHAR_ARRAY gl_mem_copy_array
  287. #define DGL_NTOH_CHAR_ARRAY gl_mem_copy_array
  288.  
  289. /*----------------------------------------------------------------------*/
  290. /* these macros are the same on all machines because the procedure */
  291. /* code invokes the appropriate conversion macro within a loop */
  292. /*----------------------------------------------------------------------*/
  293. #define DGL_HTON_SHORT_ARRAY gl_mem_hton_short_array
  294. #define DGL_NTOH_SHORT_ARRAY gl_mem_ntoh_short_array
  295. #define DGL_HTON_LONG_ARRAY gl_mem_hton_long_array
  296. #define DGL_NTOH_LONG_ARRAY gl_mem_ntoh_long_array
  297. #define DGL_HTON_FLOAT_ARRAY gl_mem_hton_float_array
  298. #define DGL_NTOH_FLOAT_ARRAY gl_mem_ntoh_float_array
  299. #define DGL_HTON_DOUBLE_ARRAY gl_mem_hton_double_array
  300. #define DGL_NTOH_DOUBLE_ARRAY gl_mem_ntoh_double_array
  301. #define DGL_HTON_FONTCHAR_ARRAY gl_mem_hton_fontchar_array
  302. #define DGL_NTOH_FONTCHAR_ARRAY gl_mem_ntoh_fontchar_array
  303. #define DGL_HTON_LFONTCHAR_ARRAY gl_mem_hton_lfontchar_array
  304. #define DGL_NTOH_LFONTCHAR_ARRAY gl_mem_ntoh_lfontchar_array
  305. #define DGL_HTON_FMFONTINFO_ARRAY gl_mem_hton_fmfontinfo_array
  306. #define DGL_NTOH_FMFONTINFO_ARRAY gl_mem_ntoh_fmfontinfo_array
  307. #define DGL_HTON_FMGLYPHINFO_ARRAY gl_mem_hton_fmglyphinfo_array
  308. #define DGL_NTOH_FMGLYPHINFO_ARRAY gl_mem_ntoh_fmglyphinfo_array
  309. #define DGL_NTOH_WFMOUTLINE_ARRAY gl_mem_ntoh_wfmoutline_array
  310.  
  311. /*----------------------------------------------------------------------*/
  312. /* DGL_BIG_ENDIAN: no conversion necessary (INTEGER) */
  313. /*----------------------------------------------------------------------*/
  314. #ifdef    CRAY
  315. extern long dgl_ntoh_long();
  316. extern short dgl_ntoh_short();
  317. #define DGL_HTON_CMD(t,f) DGL_HTON_LONG(t,f)
  318. #define DGL_NTOH_LONG(t,f)  t = dgl_ntoh_long(f)
  319. #define DGL_NTOH_SHORT(t,f)  t = dgl_ntoh_short(f)
  320. #else
  321. #if MACHINE_WORD_FORMAT == DGL_BIG_ENDIAN
  322. #define DGL_HTON_CMD(t,f) t = f        
  323. #define DGL_HTON_SHORT(t,f) t = f
  324. #define DGL_NTOH_SHORT DGL_HTON_SHORT
  325. #define DGL_HTON_LONG(t,f) t = f
  326. #define DGL_NTOH_LONG DGL_HTON_LONG
  327. #endif
  328. #endif
  329.  
  330. /*----------------------------------------------------------------------*/
  331. /* DGL_BIG_IEEE: no conversion necessary (FLOAT) */
  332. /*----------------------------------------------------------------------*/
  333. #ifdef CRAY
  334. extern float dgl_ntoh_float();
  335. extern float dgl_ntoh_double();
  336. #define DGL_NTOH_FLOAT(t,f)  t = dgl_ntoh_float(f)
  337. #define DGL_NTOH_DOUBLE(t,f)  t = dgl_ntoh_double(f)
  338. #else     /* !CRAY */
  339. #if MACHINE_FLOAT_FORMAT == DGL_BIG_IEEE
  340. #define DGL_HTON_FLOAT(t,f) t = f
  341. #define DGL_NTOH_FLOAT DGL_HTON_FLOAT
  342. #define DGL_HTON_DOUBLE(t,f) memcpy(&(t),&(f),sizeof(double))
  343. #define DGL_NTOH_DOUBLE DGL_HTON_DOUBLE
  344. #endif
  345. #endif
  346.  
  347. /*----------------------------------------------------------------------*/
  348. /* DGL_LITTLE_ENDIAN: conversion necessary (INTEGER) */
  349. /*    NOTE: non-floating point conversions are the same for both */
  350. /*        directions and thus one macro suffices */
  351. /*----------------------------------------------------------------------*/
  352. #if MACHINE_WORD_FORMAT == DGL_LITTLE_ENDIAN
  353. /* like DGL_HTON_LONG, but more efficient if f is a constant */
  354. #define DGL_HTON_CMD(t,f)  t = (f << 24) | ((f & 0xff00) << 8) |    \
  355.             ((f & 0xff0000) >> 8) | ((f >> 24) & 0xff)
  356. #define DGL_HTON_SHORT(t,f)     \
  357.     {            \
  358.         short _from = f,_to;    \
  359.         ((char *)&_to)[0] = ((char *)&_from)[1];    \
  360.         ((char *)&_to)[1] = ((char *)&_from)[0];    \
  361.         t = _to;    \
  362.     }
  363. #define DGL_NTOH_SHORT DGL_HTON_SHORT
  364. #define DGL_HTON_LONG(t,f)    \
  365.     {            \
  366.         long _from = f,_to;    \
  367.         ((char *)&_to)[0] = ((char *)&_from)[3];    \
  368.         ((char *)&_to)[1] = ((char *)&_from)[2];    \
  369.         ((char *)&_to)[2] = ((char *)&_from)[1];    \
  370.         ((char *)&_to)[3] = ((char *)&_from)[0];    \
  371.         t = _to;    \
  372.     }
  373. #define DGL_NTOH_LONG DGL_HTON_LONG
  374. #endif
  375.  
  376. /*----------------------------------------------------------------------*/
  377. /* DGL_NON_IEEE: conversion necessary (FLOAT) */
  378. /*    conversion is done within procedure calls for simplicity */
  379. /*----------------------------------------------------------------------*/
  380. #if MACHINE_FLOAT_FORMAT == DGL_NON_IEEE
  381. #define DGL_HTON_FLOAT(t,f) gl_mem_hton_float(&t,&f)
  382. #define DGL_NTOH_FLOAT(t,f) gl_mem_ntoh_float(&t,&f)
  383. #define DGL_HTON_DOUBLE(t,f) gl_mem_hton_double(&t,&f)
  384. #define DGL_NTOH_DOUBLE(t,f) gl_mem_ntoh_double(&t,&f)
  385. #endif
  386.  
  387. /*----------------------------------------------------------------------*/
  388. /* copy & convert a fontchar structure */
  389. /*----------------------------------------------------------------------*/
  390. #ifdef CRAY
  391. #define DGL_HTON_FONTCHAR(t,f)    {        \
  392.     ((char *)t)[0] = (f).offset >> 8;     \
  393.     ((char *)t)[1] = (f).offset;         \
  394.     ((char *)t)[2] = (f).w;            \
  395.     ((char *)t)[3] = (f).h;            \
  396.     ((char *)t)[4] = (f).xoff;        \
  397.     ((char *)t)[5] = (f).yoff;        \
  398.     ((char *)t)[6] = (f).width >> 8;    \
  399.     ((char *)t)[7] = (f).width;        \
  400. }
  401. #define DGL_NTOH_FONTCHAR(t,f)    {        \
  402.     (t).offset = ((unsigned char *)f)[0] << 8 | ((unsigned char *)f)[1];    \
  403.     (t).w    = ((unsigned char *)f)[2];    \
  404.     (t).h    = ((unsigned char *)f)[3];    \
  405.     (t).xoff = ((unsigned char *)f)[4];    \
  406.     (t).yoff = ((unsigned char *)f)[5];    \
  407.     (t).width = ((unsigned char *)f)[6] << 8 | ((unsigned char *)f)[7];    \
  408.     if (((unsigned char *)f)[6] & 0x80)    \
  409.         (t).width |= ~0xffff;        \
  410. }
  411. #define DGL_HTON_LFONTCHAR(t,f)    {        \
  412.     ((char *)t)[0] = (f).value >> 24;     \
  413.     ((char *)t)[1] = (f).value >> 16;     \
  414.     ((char *)t)[2] = (f).value >> 8;     \
  415.     ((char *)t)[3] = (f).value;         \
  416.     ((char *)t)[4] = (f).offset >> 24;     \
  417.     ((char *)t)[5] = (f).offset >> 16;     \
  418.     ((char *)t)[6] = (f).offset >> 8;     \
  419.     ((char *)t)[7] = (f).offset;         \
  420.     ((char *)t)[8] = (f).w >> 8;        \
  421.     ((char *)t)[9] = (f).w;            \
  422.     ((char *)t)[10] = (f).h >> 8;        \
  423.     ((char *)t)[11] = (f).h;        \
  424.     ((char *)t)[12] = (f).xoff >> 8;    \
  425.     ((char *)t)[13] = (f).xoff;        \
  426.     ((char *)t)[14] = (f).yoff >> 8;    \
  427.     ((char *)t)[15] = (f).yoff;        \
  428.     ((char *)t)[16] = (f).xmove >> 8;    \
  429.     ((char *)t)[17] = (f).xmove;        \
  430.     ((char *)t)[18] = (f).ymove >> 8;    \
  431.     ((char *)t)[19] = (f).ymove;        \
  432. }
  433. #define DGL_NTOH_LFONTCHAR(t,f)    {        \
  434.     (t).value = ((unsigned char *)f)[0] << 24 | ((unsigned char *)f)[1] << 16 | ((unsigned char *)f)[2] << 8 | ((unsigned char *)f)[3]; \
  435.     (t).offset = ((unsigned char *)f)[4] << 24 | ((unsigned char *)f)[5] << 16 | ((unsigned char *)f)[6] << 8 | ((unsigned char *)f)[7]; \
  436.     (t).w = ((unsigned char *)f)[8] << 8 | ((unsigned char *)f)[9]; \
  437.     if (((unsigned char *)f)[8] & 0x80)    \
  438.         (t).w |= ~0xffff;        \
  439.     (t).h = ((unsigned char *)f)[10] << 8 | ((unsigned char *)f)[11]; \
  440.     if (((unsigned char *)f)[10] & 0x80)    \
  441.         (t).h |= ~0xffff;        \
  442.     (t).xoff = ((unsigned char *)f)[12] << 8 | ((unsigned char *)f)[13]; \
  443.     if (((unsigned char *)f)[12] & 0x80)    \
  444.         (t).xoff |= ~0xffff;        \
  445.     (t).yoff = ((unsigned char *)f)[14] << 8 | ((unsigned char *)f)[15]; \
  446.     if (((unsigned char *)f)[14] & 0x80)    \
  447.         (t).yoff |= ~0xffff;        \
  448.     (t).xmove = ((unsigned char *)f)[16] << 8 | ((unsigned char *)f)[17]; \
  449.     if (((unsigned char *)f)[16] & 0x80)    \
  450.         (t).xmove |= ~0xffff;        \
  451.     (t).ymove = ((unsigned char *)f)[18] << 8 | ((unsigned char *)f)[19]; \
  452.     if (((unsigned char *)f)[18] & 0x80)    \
  453.         (t).ymove |= ~0xffff;        \
  454. }
  455. #else
  456. #define DGL_HTON_FONTCHAR(t,f)    {        \
  457.     DGL_HTON_SHORT((t).offset,(f).offset);    \
  458.     DGL_HTON_CHAR((t).w,(f).w);        \
  459.     DGL_HTON_CHAR((t).h,(f).h);        \
  460.     DGL_HTON_CHAR((t).xoff,(f).xoff);    \
  461.     DGL_HTON_CHAR((t).yoff,(f).yoff);    \
  462.     DGL_HTON_SHORT((t).width,(f).width);    \
  463. }
  464. #define DGL_NTOH_FONTCHAR DGL_HTON_FONTCHAR
  465. #define DGL_HTON_LFONTCHAR(t,f)    {        \
  466.     DGL_HTON_LONG((t).value,(f).value);        \
  467.     DGL_HTON_LONG((t).offset,(f).offset);    \
  468.     DGL_HTON_SHORT((t).w,(f).w);        \
  469.     DGL_HTON_SHORT((t).h,(f).h);        \
  470.     DGL_HTON_SHORT((t).xoff,(f).xoff);    \
  471.     DGL_HTON_SHORT((t).yoff,(f).yoff);    \
  472.     DGL_HTON_SHORT((t).xmove,(f).xmove);    \
  473.     DGL_HTON_SHORT((t).ymove,(f).ymove);    \
  474. }
  475. #define DGL_NTOH_LFONTCHAR DGL_HTON_LFONTCHAR
  476.  
  477. #define DGL_HTON_FMGLYPHINFO(t,f)    {        \
  478.     DGL_HTON_LONG((t).xsize,(f).xsize);    \
  479.     DGL_HTON_LONG((t).ysize,(f).ysize);    \
  480.     DGL_HTON_LONG((t).xorig,(f).xorig);    \
  481.     DGL_HTON_LONG((t).yorig,(f).yorig);    \
  482.     DGL_HTON_FLOAT((t).xmove,(f).xmove);    \
  483.     DGL_HTON_FLOAT((t).ymove,(f).ymove);    \
  484.     DGL_HTON_LONG((t).gtype,(f).gtype);    \
  485.     DGL_HTON_LONG((t).bitsdeep,(f).bitsdeep);    \
  486. }
  487. #define DGL_NTOH_FMGLYPHINFO DGL_HTON_FMGLYPHINFO
  488.  
  489. #define DGL_HTON_FMFONTINFO(t,f)    {        \
  490.     DGL_HTON_LONG((t).printermatched,(f).printermatched);    \
  491.     DGL_HTON_LONG((t).reserved0,(f).reserved0);    \
  492.     DGL_HTON_DOUBLE((t).matrix00,(f).matrix00);    \
  493.     DGL_HTON_DOUBLE((t).matrix01,(f).matrix01);    \
  494.     DGL_HTON_DOUBLE((t).matrix10,(f).matrix10);    \
  495.     DGL_HTON_DOUBLE((t).matrix11,(f).matrix11);    \
  496.     DGL_HTON_LONG((t).type,(f).type);    \
  497.     DGL_HTON_LONG((t).encoding,(f).encoding);    \
  498.     DGL_HTON_LONG((t).fixed_width,(f).fixed_width);    \
  499.     DGL_HTON_LONG((t).xorig,(f).xorig);    \
  500.     DGL_HTON_LONG((t).yorig,(f).yorig);    \
  501.     DGL_HTON_LONG((t).xsize,(f).xsize);    \
  502.     DGL_HTON_LONG((t).ysize,(f).ysize);    \
  503.     DGL_HTON_LONG((t).height,(f).height);    \
  504.     DGL_HTON_LONG((t).nglyphs,(f).nglyphs);    \
  505.     DGL_HTON_LONG((t).bitsdeep,(f).bitsdeep);    \
  506.     DGL_HTON_LONG((t).width,(f).width);    \
  507.     DGL_HTON_LONG((t).resolution,(f).resolution);    \
  508.     DGL_HTON_LONG((t).weight,(f).weight);    \
  509.     DGL_HTON_LONG((t).reserved1,(f).reserved1);    \
  510.     DGL_HTON_LONG((t).reserved2,(f).reserved2);    \
  511.     DGL_HTON_LONG((t).reserved3,(f).reserved3);    \
  512. }
  513. #define DGL_NTOH_FMFONTINFO DGL_HTON_FMFONTINFO
  514. #endif     /* CRAY */
  515.  
  516. /*----------------------------------------------------------------------*/
  517. /*            SECTION 5 - internal DGL statements */
  518. /*             *** DO NOT CHANGE ANYTHING BELOW HERE *** */
  519. /*----------------------------------------------------------------------*/
  520.  
  521. #ifndef NULL            /* define NULL in not already defined    */
  522. #define NULL    0
  523. #endif
  524.  
  525. #define DGL_VERSION 1        /* old DGL version number        */
  526. #define DGL_NEW_VERSION 2    /* current DGL version (supports Xauthority) */
  527. #define CMD_SPECIAL 0x00001234    /* special token to check byte ordering    */
  528. #define RETAINED 0x80000000    /* special negative number for arrays    */
  529. #define MAXARGS 100        /* maximum number of args per DGL routine */
  530. #define MAXCALLBACKS 16        /* maximum number of callback procedures*/
  531. #define COMMBUFSIZE (4*1024)    /* default comm buffer size in bytes    */
  532. #define AVGSIZE 20        /* average size (bytes) of command    */
  533. #define END_OF_BUFFER 0        /* special DGL command token        */
  534. #define DGL_NOP -1        /* special DGL command token        */
  535. #define RESET_COMM_CURBUFPOS comm_curbufpos = comm_buffer + 4
  536. #define RESET_COMM_ENDBUFFER    \
  537.     comm_endbuffer = comm_buffer + comm_stdsize - 4 - AVGSIZE
  538.  
  539. #define MAX_GFILES 256        /* maximum number of gfiles        */
  540. #define DGL_MAXIO 0x37777770    /* maximum number of bytes per i/o    */
  541. #define DGL_LASTFRAG 0x10000000    /* high bit of 32 bit word        */
  542.  
  543. /*----------------------------------------------------------------------*/
  544. /* get/set a data item located at address p regardless what it really is */
  545. /*----------------------------------------------------------------------*/
  546. #ifdef CRAY
  547. #define LONG(p) (p)
  548. #define FLOAT(p) (p)
  549. #define DOUBLE(p) (p)
  550. #define SHORT(p) (p)
  551. #define FONTCHAR(p) (p)
  552. #define LFONTCHAR(p) (p)
  553. #define CHAR(p) (*(char *)(p))
  554. #else /* !CRAY */
  555. #define LONG(p) (*(long *)(p))
  556. #define FLOAT(p) (*(float *)(p))
  557. #define DOUBLE(p) (*(double *)(p))
  558. #define SHORT(p) (*(short *)(p))
  559. #define CHAR(p) (*(char *)(p))
  560. #define FONTCHAR(p) (*(Fontchar *)(p))
  561. #define LFONTCHAR(p) (*(Lfontchar *)(p))
  562. #define FMGLYPHINFO(p) (*(fmglyphinfo *)(p))
  563. #define FMFONTINFO(p) (*(fmfontinfo *)(p))
  564. #endif
  565.  
  566. /*----------------------------------------------------------------------*/
  567. /* this is the graphics file data structure */
  568. /*----------------------------------------------------------------------*/
  569. typedef struct gfile {
  570.     int id;            /* my id (index into table)        */
  571.     int type;            /* type of connection            */
  572.     int maxio;            /* maximum bytes for one i/o operation    */
  573.     int fd_read;        /* file descriptor for reading        */
  574.     int fd_write;        /* file descriptor for writing        */
  575.     int fd_extra;        /* extra one for special hacks        */
  576.     int (*readproc)();        /* read data procedure            */
  577.     int (*writeproc)();        /* write data procedure            */
  578.     int (*closeproc)();        /* close file procedure            */
  579.     char fname_read [80];    /* the 2 file names            */
  580.     char fname_write[80];
  581.     int fd_queue;        /* queue file descriptor        */
  582.     char rhost[200];
  583.     int floatfeedback;        /* boolean: use floats or shorts    */
  584.     int isdefault;        /* this is default connection        */
  585.     int is4xrelease;        /* this connection to a 4.0.x release    */
  586. } Gfile;
  587.  
  588. extern Gfile *comm_gfiles[];    /* all the gfiles            */
  589. extern Gfile *comm_curgfile;    /* the current gfile            */
  590.  
  591. extern char *comm_buffer;            /* THE BUFFER        */
  592.  
  593. extern long dgl_debug;                /* debug flag        */
  594. extern int dgl_errors;                /* error counter    */
  595. extern int dgl_testmode;            /* test mode flag    */
  596. extern int dgl_exitflag;            /* exit flag        */
  597. extern int dgl_glprof;                /* profiling flag    */
  598. extern int dgl_positional;            /* test variable    */
  599. extern int (*dgl_interpreter)();        /* the dgl interpreter    */
  600.  
  601. extern float gl_util_timer();            /* utility timer    */
  602.  
  603. /* dgld versions follow */
  604.  
  605. extern Gfile *dcom_gfiles[];    /* all the gfiles            */
  606. extern Gfile *dcom_curgfile;    /* the current gfile            */
  607.  
  608. extern char *dgld_myname;            /* the program's name    */
  609. extern char *dcom_buffer;            /* THE BUFFER        */
  610.  
  611. extern long dgld_debug;                /* debug flag        */
  612. extern int dgld_errors;                /* error counter    */
  613. extern int dgld_testmode;            /* test mode flag    */
  614. extern int dgld_exitflag;            /* exit flag        */
  615. extern int dgld_glprof;                /* profiling flag    */
  616. extern int dgld_positional;            /* test variable    */
  617. extern int (*dgld_interpreter)();        /* the dgl interpreter    */
  618.  
  619. extern signed char gen_char();            /* test routine        */
  620. extern float gen_float();            /* test routine        */
  621. extern float util_timer();            /* utility timer    */
  622.  
  623. #endif /* __GL_DGL_H__ */
  624.